$(function () {
    var header = new Vue({
        el: "#header",
        data: {
            down: false,
            startX: "",
            endX: "",
            p_position: {},
        },
        methods: {
            onMouseDown : function(event) {
                var self = this;
                self.down = true;
                event = event || window.Event;
                self.startX = event.clientX;
                $('body').mousemove(function (e) {
                    e = e || window.Event;
                    if(self.down) {
                        self.p_position = {
                            left: e.clientX - 20 + "px",
                            top: e.clientY - 20 + "px"
                        }
                    }
                });
            },
            onMouseUp : function(e) {
                this.down = false;
                e = e || window.Event;
                this.endX = e.clientX;
                if(this.endX == this.startX) {
                    var left = $("#left");
                    var right = $("#right");
                    if (e.target.classList.contains("left")) {
                        e.target.classList.remove("left");
                        e.target.classList.add("right");
                        left.css({
                            "width": "0px",
                            "overflow": "hidden",
                            "border": "none"
                        });
                        right.css({
                            "width": "100%",
                        });
                    } else {
                        e.target.classList.remove("right");
                        e.target.classList.add("left");
                        left.removeAttr("style");
                        right.removeAttr("style");
                    }
                }
            },
            GetQueryString: function (name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null)return unescape(r[2]);
                return null;
            }
        }
    });
});
